// watchEffect来自于'./reactive.js'文件
// patch、 mount 来自于'./renderer.js'文件
function createApp(rootComponent) {
    return {
        mount(selector) {
            const container = document.querySelector(selector)
            let isMounted = false; // 判断是否挂载过
            let oldVNode = null; // 用于保存最新的vnode
            watchEffect(function() {
                if (!isMounted) {
                    oldVNode = rootComponent.render()
                    mount(oldVNode, container)
                    isMounted = true
                } else {
                    const newVNode = rootComponent.render()
                    patch(oldVNode, newVNode) // 更新补丁
                    oldVNode = newVNode
                }
            })
        }
    }
}